import { Injectable } from '@nestjs/common';
import * as Minio from 'minio';
import { minioConfig } from '../../config/config';

@Injectable()
export class MinioService {
  private readonly minioClient: Minio.Client;

  constructor() {
    this.minioClient = new Minio.Client(minioConfig);
  }

  async uploadFile(bucketName: string, objectName: string, data: Buffer) {
    await this.minioClient.putObject(bucketName, objectName, data);
    return `${minioConfig.prefix}/${bucketName}/${objectName}`;
  }
}
